#
# 二分探索木のテスト
#
use Bintree;

package Number;

sub new {
  my ($type, $num) = @_;
  my $obj = { 'value' => $num };
  bless $obj, 'Number';
  $obj;
}

sub compare {
  my ($obj1, $obj2) = @_;
  $obj1->{'value'} <=> $obj2->{'value'};
}

sub print_object {
  my $obj = shift;
  print $obj->{'value'}, "\n";
}

package main;

$root = Bintree->make_tree();
for( $i = 0; $i < 10; $i++ ){
  my $num = rand();
  my $obj = Number->new( $num );
  $root = $root->insert_tree( $obj );
  print $num, "\n";
}

print "---- output tree ----\n";
$root->print_tree();

# end of file
